package com.man.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.man.bean.AdminMan;
import com.man.bean.People;
import com.man.dao.AdminDao;
import com.man.dao.PeopleDao;



/**
 * Servlet implementation class RegistServlet
 */
@WebServlet("/changpwd")
public class ChangePwdServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String account = (String) request.getSession().getAttribute("account");
		String pow = (String) request.getSession().getAttribute("pow");
		String pwd = request.getParameter("pwd");
		AdminMan peo = new AdminMan();
		peo.setAccount(account);
		peo.setPassword(pwd);
		peo.setPow(pow);
		int num=new AdminDao().changePwd(peo);
	
	
		if(num==1) {
			request.getSession().setAttribute("st", "更改成功");
		
		}else {
			
			request.getSession().setAttribute("st", "更改失败");
			
		}
		response.sendRedirect("pen/hotel.jsp");
	}
}
